<%@ page contentType="text/html; charset=utf-8"%>

<div id="gradeDiv" style="width: 1168px;display: none;">

	<div>
		<span style="margin-top: 16px;">时间：</span><input type="text" id="gradeDate"  style="margin-top: 7px;">
		<select id="gradeDateType" style="margin-top: 7px;width: 60px;height: 28px;font-size: 14px;">
			<option value="按日">按日</option>
			<option value="按周">按周</option>
			<option selected="selected" value="按月">按月</option>
		</select>
		 <input type="button" onclick="getGradeData()" style="width: 100px;margin-left: 30px;" class="btn btn-primary m_r" value="查询">
		 	<input type="button" onclick="exportReportGrade()" style="width: 100px;" class="btn btn-primary m_r" value="导出报表"></input>
	</div>
	<div>
	
	   <table class="table table-striped table-bordered" id="gradeTable"> </table>
	
	
	</div >
		<div style="margin: 0 auto;width: 700px; text-align: center;font-size: 14px; display: none;">
	
	  		<a href="#" >上页</a><a href="#" style="margin-left: 10px;">下页</a> <input type="text" style="width: 30px;margin-left: 10px;" value="1"> /12 <a href="#" style="margin-left: 10px;">跳转</a>
	
	</div>
</div>


<script>


	var gradeDate,gradeDateType;

	$(function() {
		$("#gradeDate").datepicker();
		iniGradeData();
	});
	function iniGradeData(){
		
		
		
		 $("#gradeDate").val(date2str(new Date(),"yyyy-MM-dd"));

		 getGradeData();
	}
	
	function exportReportGrade(){
		
		getGradeData();
		
		
		if(gradeDate==null||gradeDate==""){
			return ;
		}
	
		
		showCommonDiv();
				$.post("exportReport", {"types":"gradeData","gradeDate":gradeDate,"gradeDateType":gradeDateType},
					   function(data){
					closeCommonDiv();
					
						if(data!="false"){
							window.location.href="exportReport?types=downFile&&fileName="+data; 
						}
					},"json");
			
	}
	
	
	function getGradeData(){
		
		
		gradeDate = $("#gradeDate").val();
		gradeDateType = $("#gradeDateType").val();
		
		
		
		if(gradeDate==null||gradeDate==""){
			
			
			alert("请选择时间");
			return ;
		}
		showCommonDiv();
		$.post("getData", {"types":"gradeData", 
			"gradeDate":gradeDate,"gradeDateType":gradeDateType},
				   function(data){
				closeCommonDiv();
				if(data!=null){
					
					setGradeData(data);	
				}
				
				   },"json");
		
	}
	
	
	function setGradeData(data){
		var tableVal = "<thead><tr><th>排名</th><th>网页测试得分</th><th>时延得分</th><th>抖动得分</th><th>丢包得分</th><th>网页测试次数</th><th>下载测试得分</th><th>下载测试次数</th><th>公司</th><th>时间</th> </tr></thead><tbody >";
		for(var i = 0 ;i < data.length;i++){
			var obj = data[i];
			if(i==0){
				tableVal = tableVal+"<tr><td>-</td><td>"+obj.webGrade+"</td><td>"+obj.webtimedelayGrade+"</td><td>"+obj.webShakeGrade+"</td><td>"+obj.weblostRateGrade+"</td>"+
				"<td>"+obj.webTestCount+"</td><td>"+obj.downFileGrade+"</td><td>"+obj.downFileTestCount+"</td><td>所有公司</td><td rowspan='"+data.length+"' style='text-align:center' >"+obj.time+"</td></tr>";
			}else{
				tableVal = tableVal+"<tr><td>"+i+"</td><td>"+obj.webGrade+"</td><td>"+obj.webtimedelayGrade+"</td><td>"+obj.webShakeGrade+"</td><td>"+obj.weblostRateGrade+"</td><td>"+obj.webTestCount
				+"</td><td>"+obj.downFileGrade+"</td><td>"+obj.downFileTestCount+"</td><td>"+obj.vlanId+"</td></tr>";
			}
		}
		tableVal = tableVal+"</tbody>";
		
		$("#gradeTable").html(tableVal);
		
	}
	
	
	
</script>


